<?php 
	require_once('init.php');
	function getDrivers($class, $fuel) {
		$fuel = strtolower($fuel);
		$sql = 'select description, model, engine, horsepower, torque, weight from driver WHERE fuel="' . $fuel . '" AND class_id="' . $class . '"'; 
		$res = mysql_query($sql); 
		$kierowcy = array(); 
		while ($row = mysql_fetch_assoc($res)) $kierowcy[] = $row;
		return $kierowcy;
		
	}
	function drawFuelType($type = 'PB') {
		return '<h2><img src="images/fuel.png" height="48"  /> Fuel Type: ' . strtoupper($type) . '</h2>';
	}
	function drawGrid($drivers, $class = '90') {
		$txt = '<table class="table-3"><tr><td>&nbsp;</td>';
		foreach ($drivers as $kier_row) {
			$txt.='<td><font size=2><span class="tooltip" href="#"><font size="1">' . $kier_row['description'] . '</font>
				<span class="custom info"><img src="images/tooltip/Info.png" alt="Information" height="48" width="48" />
					<em>Information</em>
					Model: ' . $kier_row['model']. ' <br/> 
					Engine: ' . $kier_row['engine']. '  <br/> 
					Horsepower: ' . $kier_row['horsepower']. '  Hp <br/>
					Torque: ' . $kier_row['torque']. '   Nm <br/> 
					Weight: ' . $kier_row['weight']. '   Kg
				</span>
			</font>';
		}
		$txt.= '</td></tr>';
		$curr = 0;
		foreach ($drivers as $kier_row) { 
			$txt.='<tr>'; 
			$txt.='<td><font size=2><span class="tooltip" href="#"><font size=1>' . $kier_row['description'] . '</font>
				<span class="custom info"><img src="images/tooltip/Info.png" alt="Information" height="48" width="48" />
									<em>Information</em>
										Model: ' . $kier_row['model']. ' <br/> 
										Engine: ' . $kier_row['engine']. '  <br/> 
										Horsepower: ' . $kier_row['horsepower']. '  Hp <br/>
										Torque: ' . $kier_row['torque']. '   Nm <br/> 
										Weight: ' . $kier_row['weight']. '   Kg
								</span>
				
				</font></td>'; 
			 for ($i=0;$i<count($drivers);$i++) { 
				 $txt.='<td>'; 
				 if ($i == $curr) {
				 	$txt.='<center><img src=images/class/' . $class . 'small.png width=64/></center>'; 
				 } else {
				 	$txt.='&nbsp;'; 
				 }
				 $txt.='</td>'; 
			 } // for i = 0 to count drivers
			 $txt.='</tr>';
			 $curr++; 
		} // foreach drivers as kier_row
		$txt.='</table>';
		return $txt;
	}
?>
<!DOCTYPE html>
<html>
<head>
<title>Silesia Racing Drag Race</title>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="accordion/accordionstyle.css" />
        <script type="text/javascript" src="accordion/jQuery.1.4.2.min.js"></script>
        <script type="text/javascript" src="accordion/jQuery.simpleAccordion.js"></script>
        <script type="text/javascript">
		$(document).ready(function(){
			$('#simple-accordion').simpleAccordion({collapsed: true,expanded: 5});
		});
        </script>

</head>
<body>
    <div id="wrapper">
        <div id="headerwrap">
        <div id="header">
           <p align="right"> Silesia Racing Drag Race</p>
        </div>
        </div>
		<div id="topwrap">
        <div id="top_components">
           <h2>League</h2>
        </div>
        </div>
        <div id="leftcolumnwrap">
        <div id="leftcolumn">
            <?php include_once ('menu_left.php');?>
        </div>
        </div>
        <div id="contentwrap">
        <div id="content">
		<div>   

		<div id="simple-accordion">
		    <a href="#" class="league">Class 0+</a>
		    <div>
		        <?php
		       		$drivers = getDrivers(SR_L_CLASS_0, 'on');
		       		echo drawFuelType('ON');
		       		echo drawGrid($drivers, '0');
		       		
		       		$drivers = getDrivers(SR_L_CLASS_0, 'pb');
		       		echo drawFuelType('PB');
		       		echo drawGrid($drivers, '0');
		        ?>
				<?php /* include_once ('league_class0.php'); */ ?>
		    </div>
		    <a href="#" class="league">Class 90+</a>
		    <div>
		   		<?php
		       		$drivers = getDrivers(SR_L_CLASS_90, 'on');
		       		echo drawFuelType('ON');
		       		echo drawGrid($drivers, '90');
		       		
		       		$drivers = getDrivers(SR_L_CLASS_90, 'pb');
		       		echo drawFuelType('PB');
		       		echo drawGrid($drivers, '90');
		        ?>
				<?php /*include_once ('league_class90.php');*/ ?>
		    </div>
		    <a href="#" class="league">Class 150+</a>
		    <div>
		   		<?php
		       		$drivers = getDrivers(SR_L_CLASS_150, 'on');
		       		echo drawFuelType('ON');
		       		echo drawGrid($drivers, '150');
		       		
		       		$drivers = getDrivers(SR_L_CLASS_150, 'pb');
		       		echo drawFuelType('PB');
		       		echo drawGrid($drivers, '150');
		        ?>
				<?php /*include_once ('league_class150.php');*/ ?>
			</div>
		    <a href="#" class="league">Class 200+</a>
		    <div>
		    	<?php
		       		$drivers = getDrivers(SR_L_CLASS_200, 'on');
		       		echo drawFuelType('ON');
		       		echo drawGrid($drivers, '200');
		       		
		       		$drivers = getDrivers(SR_L_CLASS_200, 'pb');
		       		echo drawFuelType('PB');
		       		echo drawGrid($drivers, '200');
		        ?>
				<?php /*include_once ('league_class200.php');*/ ?>
		    </div>
		    <?php /*
		    <!--<a href="#" class="league">Class 300+</a>
		    <div>
		        <p>
				<?php //include_once ('league_class300.php');?>
				</p>
		    </div>--> */ ?>
		</div>

		</div>
        </div>
        </div>
        <div id="rightcolumnwrap">
	        <div id="rightcolumn">
				<?php include_once ('right_column.php');?>
	        </div>
        </div>
        <div id="footerwrap">
	        <div id="footer">
	            <p>Silesia Racing Drag Race by Tomasz Kargol</p>
	        </div>
        </div>
    </div>
</body>
</html>
